Changes to filename_template checks #1464
Conversation
|
I've run a few quick tests, and it looks like the core logic is now functioning as expected. I had just a couple of ideas that might clean up the implementation:
|
I've incorporated the 2nd idea in the most recent commit. But having either the outer loop or the inner loop consider only output streams, appears to miss some filename conflicts, due to the directionality introduced by idea #2. |
| message = 'Found identical values of the filename_template attribute for multiple active output streams, ' & | ||
| // trim(stream1_cursor % name) // ' and ' // trim(stream2_cursor % name) // & | ||
| ', in streams.<CORE>. This may result in file conflicts.' | ||
| call mpas_log_write(message, messageType=MPAS_LOG_ERR) |
There was a problem hiding this comment.
The error message can be quite long when printed to a single line, e.g.,
ERROR: Found identical values of the filename_template attribute for multiple active output streams, restart and output, in streams.<CORE>. This may result in file conflicts.
It might be better to explicitly write a multi-line error message with multiple calls to mpas_log_write.
There was a problem hiding this comment.
@abishekg7 It looks like this suggestion is still pending.
There was a problem hiding this comment.
The previous message has actually been modified slightly, and it is split up into two calls to mpas_log_write. Let me know if it needs further changes.
|
I have addressed the remaining suggestions in the last few commits. |
|
@abishekg7 As of now, there are quite a few messages that are written to the log file even when there are no issues with the streams. For example, here's what I get from the log file for the Could you update the PR so that these messages are not written? |
Done. |
Issue:
Previously, if two active, output stream definitions in the streams. file specified the same string as the
filename_templateattribute, the corresponding MPAS CORE would crash with an error message. This was also the case for when one of the streams, sharing thefilename_template, included an inactive package, hence effectively making it inactive. The existing logic to perform stream uniqueness checks insrc/framework/xml_stream_parser.cdid not have the information about which packages associated with a stream were active, and hence did not account for inactive packages.Solution
This PR introduces a new subroutine
MPAS_stream_mgr_check_filename_templateinsrc/framework/mpas_stream_manager.Fto check whether two active streams might potentially be accessing the same file (viafilename_template) resulting in file conflicts. More specifically, this subroutine checks that there are no active output streams that share an identicalfilename_templateattribute with any other active input or output streams in the stream manager. An active stream in this context is a stream with attributeactive_stream = .true.and is not deactivated by an inactive package and is either an input or output stream with at least one active alarm. This routine can be called from withinMPAS_stream_mgr_validate_streamsor separately as needed.This PR also introduces a new function 'MPAS_stream_mgr_get_num_alarms', which returns the number of active alarms for a given stream in the specified direction.
The previous logic to check for unique
filename_templateattributes insrc/framework/xml_stream_parser.chas been removed, while retaining the checks for unique stream names in the same location. Note that the previous logic only check for conflicts between two output streams, whereas the new logic also checks for potential conflicts between an input stream and an output stream accessing the same file.